package org.example.experiment;

import java.util.function.Consumer;

/**
 * 实验Consumer函数式接口
 */
class Person {
    String name;
    Person(String name) { this.name = name; }
}

class Employee extends Person {
    Employee(String name) { super(name); }
}

public class ConsumerExperiment {
    public static void main(String[] args) {
        Consumer<Person> personConsumer = p -> System.out.println("Person: " + p.name);
        Consumer<Employee> employeeConsumer = e -> System.out.println("Employee: " + e.name);

        Consumer<? super Employee> combined = employeeConsumer.andThen(personConsumer);

        combined.accept(new Employee("Alice"));  // 输出: Person: Alice, Employee: Alice
    }
}
